
<template>
    <div class="body">
        <el-form :rules="rules" ref="loginForm" :model="loginForm" class="loginContainer">
            <h3 class="loginTitle">
            欢迎登录
            </h3>
            <el-form-item prop="username">
                <el-input type="text" v-model="loginForm.username" placeholder="亲，请输入用户名" >
                </el-input>
            </el-form-item>
            
            <el-button type="primary" style="width:100%" @click="submitLogin">登录</el-button>
        </el-form>
    </div>
</template>

<script>
import axios from 'axios';

export default {
  name: "Login",
    data(){
      return{
          captchaUrl: "",
          loginForm:{
              username:"",
          },
          checked: true,
          rules:{
              username:[{required:true,message:"请输入用户名",trigger:"blur"},{ min: 1, max: 10, message: '长度在 1 到 10 个字符', trigger: 'blur' }
              ],
          }

      }
  },
    methods:{
      submitLogin(){
          var _this = this;
          this.$refs.loginForm.validate((valid) => {
            if (valid) {
                sessionStorage.setItem('username', this.loginForm.username);
                _this.$message({
                    message: '登录成功',
                    type: 'success'
                })
                _this.$router.push('/ChatHome');
            } 
            else {
                _this.$message.error('登录出错请重新输入');
                return false;
            }
        });
      }
    }
};
</script>

<style lang="scss" scoped>
    .loginContainer{
        border-radius: 15px;
        background-clip: padding-box;
        text-align: left;
        margin-left: 350px;
        margin-top: 180px;

        width: 350px;
        padding: 15px 35px 15px 35px;
        background: aliceblue;
        border:1px solid blueviolet;
        box-shadow: 0 0 25px #f885ff;
    }
    .loginTitle{
        margin: 0px auto 48px auto;
        text-align: center;
        font-size: 40px;
    }
    .loginRemember{
        text-align: left;
        margin: 0px 0px 15px 0px;
    }
    .body{
        width: 100vw;
        height: 100vh;
        background-size:100%;
       overflow: hidden;
    }
</style>


